Java ORB Portability Interfaces |
8 |
![]() |
org.omg.CORBA.portable
packageThe portability package contains interfaces and classes that are designed for and intended to be used by ORB implementors. It exposes the publicly defined APIs that are used to connect stubs and skeletons to the ORB.
All stubs shall inherit from a common base class org.omg.CORBA.portable.ObjectImpl
. The class is responsible for delegating shared functionality such as is_a() to the vendor specific implementation. This model provides for a variety of vendor dependent implementation choices, while reducing the client-side and server "code bloat".
All DSI-based skeletons inherit from org.omg.CORBA.DynamicImplementation
.
package org.omg.CORBA.portable;
public interface Streamable {
void _read(org.omg.CORBA.portable.InputStream istream);
void _write(org.omg.CORBA.portable.OutputStream ostream);
org.omg.CORBA.TypeCode _type();
}
The streaming APIs are found in the org.omg.CORBA.portable
package.
The ORB object is used as a factory to create an output stream. An input stream may be created from an output stream.
package org.omg.CORBA;
interface ORB {
OutputStream create_output_stream();
};
package org.omg.CORBA.portable;
public abstract class InputStream {
boolean read_boolean();
char read_char();
char read_wchar();
byte read_octet();
short read_short();
short read_uhort();
int read_long();
int read_ulong();
long read_ulongong();
float read_float();
double read_double();
String read_string();
String read_wstring();
void read_boolean_array(boolean[] value,
int offset, int length);
void read_char_array(char[] value,
int offset, int length);
void read_wchar_array(char[] value,
int offset, int length);
void read_octet_array(byte[] value,
int offset, int length);
void read_short_array(short[] value,
int offset, int length);
void read_ushort_array(short[] value,
int offset, int length);
void read_long_array(int[] value,
int offset, int length);
void read_ulong_array(int[] value,
int offset, int length);
void read_longlong_array(long[] value,
int offset, int length);
void read_ulonglong_array(long[] value,
int offset, int length);
void read_float_array(float[] value,
int offset, int length);
void read_double_array(double[] value,
int offset, int length);
org.omg.CORBA.Object read_Object();
org.omg.CORBA.TypeCode read_TypeCode();
org.omg.CORBA.Any read_any();
org.omg.CORBA.Principal read_Principal();
}
public abstract class OutputStream {
InputStream create_input_stream();
void write_boolean (boolean value);
void write_char (char value);
void write_wchar (char value);
void write_octet (byte value);
void write_short (short value);
void write_ushort (short value);
void write_long (int value);
void write_ulong (int value);
void write_long long (long value);
void write_ulonglong (long value);
void write_float (float value);
void write_double (double value);
void write_string (String value);
void write_wstring (String value);
void write_boolean_array (boolean[] value,
int offset, int length);
void write_char_array (char[] value,
int offset, int length);
void write_wchar_array (char[] value,
int offset, int length);
void write_octet_array (byte[] value,
int offset, int length);
void write_short_array (short[] value,
int offset, int length);
void write_ushort_array (short[] value,
int offset, int length);
void write_long_array (int[] value,
int offset, int length);
void write_ulong_array (int[] value,
int offset, int length);
void write_longlong_array (long[] value,
int offset, int length);
void write_ulonglong_array (long[] value,
int offset, int length);
void write_float_array (float[] value,
int offset, int length);
void write_double_array (double[] value,
int offset, int length);
void write_Object (org.omg.CORBA.Object value);
void write_TypeCode (org.omg.CORBA.TypeCode value);
void write_any (org.omg.CORBA.Any value);
void write_Principal (org.omg.CORBA.Principal value);
}
The method _ids() returns an array of repository ids that an object implements. The string at the zero index shall represent the most derived interface. The last id, for the generic CORBA object (i.e. "IDL:omg.org/CORBA/Object:1.0"), is implied and not present.
package org.omg.CORBA.portable;
abstract public class ObjectImpl implements
org.omg.CORBA.Object {
private Delegate __delegate;
public Delegate _get_delegate() {
if (__delegate == null) {
throw new org.omg.CORBA.BAD_OPERATION();
}
return _delegate;
}
public void _set_delegate(Delegate delegate) {
__delegate = delegate;
}
String[] _ids() {...}
// methods for standard CORBA stuff
public org.omg.CORBA.ImplementationDef
_get_implementation() {
return _get_delegate().get_implementation(this);
}
public org.omg.CORBA.InterfaceDef
_get_interface() {
return _get_delegate().get_interface(this);
}
public org.omg.CORBA.Object _duplicate() {
return _get_delegate().duplicate(this);
}
public void _release() {
return _get_delegate().release(this);
}
public boolean _is_a(String repository_id) {
return _get_delegate().is_a(this, repository_id);
}
public boolean _is_equivalent(org.omg.CORBA.Object rhs) {
return _get_delegate().is_equivalent(this, rhs);
}
public boolean _non_existent() {
return _get_delegate().non_existent(this);
}
public int _hash(int maximum) {
return _get_delegate().hash(this, maximum);
}
public Request _request(String operation) {
return _get_delegate().request(this, operation);
}
public org.omg.CORBA.Request _create_request(
org.omg.CORBA.Context ctx,
String operation,
org.omg.CORBA.NVList arg_list,
org.omg.CORBA.NamedValue result) {
return _get_delegate().create_request(this, ctx,
operation, arg_list, result);
}
public Request _create_request(
org.omg.CORBA.Context ctx,
String operation,
org.omg.CORBA.NVList arg_list,
org.omg.CORBA.NamedValue result,
org.omg.CORBA.ExceptionList exceptions,
org.omg.CORBA.ContextList contexts) {
return _get_delegate().create_request(ctx, operation,
arg_list, result,exceptions, contexts);
}
}
// Java
package org.omg.CORBA.portable;
public abstract class Delegate {
org.omg.CORBA ImplementationDef get_implementation(
org.omg.CORBA.Object self);
org.omg.CORBA.InterfaceDef get_interface(
org.omg.CORBA.Object self);
org.omg.CORBA.Object duplicate(
org.omg.CORBA.Object self);
void release(org.omg.CORBA.Object self);
boolean is_a(org.omg.CORBA.Object self,
String repository_id);
boolean non_existent(org.omg.CORBA.Object self);
boolean is_equivalent(org.omg.CORBA.Object self,
org.omg.CORBA.Object rhs);
org.omg.CORBA.Request hash(org.omg.CORBA.Object self
int max);
org.omg.CORBA.Request request(org.omg.CORBA.Object self,
String operation);
org.omg.CORBA.Request create_request(
org.omg.CORBA.Object self,
org.omg.CORBA.Context ctx,
String operation,
org.omg.CORBA.NVList arg_list,
org.omg.CORBA.NamedValue result);
org.omg.CORBA.Request create_request(
org.omg.CORBA.Object self,
org.omg.CORBA.Context ctx,
String operation,
org.omg.CORBA.NVList arg_list,
org.omg.CORBA.NamedValue result,
org.omg.CORBA.ExceptionList excepts,
org.omg.CORBA.ContextList contexts);
}
See Section 7.2.2, "Servant Class" for more information.
There are several cases to consider when creating the ORB instance. An important factor is whether an applet in a browser or an stand-alone Java application is being used.
In any event, when creating an ORB instance, the class names of the ORB implementation are located using the following search order:
Property Name |
Property Value |
ORB
) must implement the set_parameters()
methods so that the initialization parameters will be passed into the ORB from the initialization methods.// Java
package org.omg.CORBA;
abstract public class ORB {
// Application init
public static ORB init(Strings[] args,
java.util.Properties props) {
set_parameters(args, props);
...
}
// Applet init
public static ORB init(Applet app,
java.util.Properties props) {
set_parameters(app, props);
...
}
// Default (singleton) init
public static ORB init()
{...}
// Implemented by subclassed ORB implementations
// and called by init methods to pass in their params
public protected void set_parameters(Strings[] args,
java.util.Properties props)
{...}
public protected void set_parameters(Applet app,
java.util.Properties props)
{...}
}
For security reasons, if called from a Java applet, the ORB may only be used to create typecodes. An attempt to invoke other "regular" ORB operations shall raise a system exception.
If called from an application a fully functional ORB object is returned.
null
.It returns a new fully functional ORB Java object each time it is called.
null
.It returns a new fully functional ORB Java object each time it is called.